package com.itheima.test;

import java.io.IOException;
import java.net.*;

public class InetAddressDemo
{
    public static void main(String[] args) throws IOException {
        InetAddress byName = InetAddress.getByName("192.168.24.27");
        String hostName = byName.getHostName();
        String hostAddress = byName.getHostAddress();
        System.out.println(hostAddress+hostName);
        //创建发送端socket对象
        DatagramSocket ds=new DatagramSocket();
        String s="天呐，我要穿越了";
        //创建数据包
        DatagramPacket dp=new DatagramPacket
                (s.getBytes(),s.length(),InetAddress.getByName("192.168.24.27"),10086);
        //发送
        ds.send(dp);
        ds.close();
    }
}
